package com.ttdev.mmms.repository;


import com.ttdev.mmms.entity.MemberInfo;
import com.ttdev.mmms.entity.StoreInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

//商店
@Repository
public interface StoreRepository {

    // 添加商家
    @Insert("INSERT INTO store_info(store_name,iphone,name,password) VALUE(#{storeName},#{iphone},#{name},#{password})")
    public int addStore(StoreInfo storeManage);

    // 查询密码
    @Select("select * from store_info where name = #{name}")
    public StoreInfo findPwd(String name);

    // 查询所有用户
    @Select("select * from store_info")
    public StoreInfo findAll(StoreInfo storeManage);

    // 查询商店名称是否存在
    @Select("select id from store_info where store_name = #{name}")
    public Integer selectStoreName(String name);

    // 查询用户名是否存在
    @Select("select id from store_info where name = #{name}")
    public Integer selectName(String name);

    // 查询用户名是否存在
    @Select("select * from member_info where card_id = #{card_id} OR iphone = #{iphone}")
    public List<MemberInfo> selectNameIpone(Integer card_id, String iphone);

    //根据卡号更改密码
    @Update("update store_info set password = #{newPassword} where store_name = #{store_name}")
    public int updatePassword(String newPassword,String store_name);
}
